|
STEP 6: Do It With Groovoids
|
You have seen how the playNote, noteOn, and noteOff methods can be used to sonify a navbar in various different ways. We will now go off on somewhat of a tangent and use Groovoids - in place of note playing - to sonify our navbar.
|
|
|
|
You can only play one file at a time through any given Music Object instance. This applies also to Groovoids since Groovoids are themselves just small musical files that are built directly into the Beatnik soundbank. If a Beatnik player is currently playing a file and you then instruct it to play a new file, the file that is currently playing will be cut short so that the new file can be played. You can see this behavior in action in the above navbar - just click on any link on the navbar and then immediately mouse over one of the other links.
Notice how the Groovoid 'Hits-Magic' that started playing gets abruptly ended so that the Beatnik player can play the 'UI-SimpleClick1' Groovoid. This is not really a problem in this example since it is expected that, when this navigation bar is used in a real life HTML page, the links will actually go somewhere and the user will then have no further opportunity to interact with the navigation bar.
Let's take a look at the source...
| |
<SCRIPT SRC="music-object.js"></SCRIPT>
<SCRIPT LANGUAGE=JavaScript><!-- //
groovoidPlayer = new Music ();
groovoidPlayer.stubEmbed ('stub.rmf');
// --></SCRIPT>
<CENTER>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD>
<A
HREF="buckingham1.html"
ONMOUSEOVER="groovoidPlayer.play ('UI-SimpleClick1')"
ONCLICK="groovoidPlayer.play ('Hits-Magic')"
>
<IMG
SRC="navbar-prev.gif"
WIDTH=96
HEIGHT=36
ALT="PREV"
BORDER=0
HSPACE=0></A></TD>
<TD>
<A
HREF="buckingham-home.html"
ONMOUSEOVER="groovoidPlayer.play ('UI-SimpleClick1')"
ONCLICK="groovoidPlayer.play ('Hits-Magic')"
>
<IMG
SRC="navbar-home.gif"
WIDTH=302
HEIGHT=36
ALT="HOME"
BORDER=0
HSPACE=0></A></TD>
<TD>
<A
HREF="buckingham3.html"
ONMOUSEOVER="groovoidPlayer.play ('UI-SimpleClick1')"
ONCLICK="groovoidPlayer.play ('Hits-Magic')"
>
<IMG
SRC="navbar-next.gif"
WIDTH=96
HEIGHT=36
ALT="NEXT"
BORDER=0
HSPACE=0></A></TD>
</TR>
</TABLE>
</CENTER>
|
We have completely lost all playNote, noteOn, and noteOff methods and are now only using the play method for the sonification. We have also dropped the setMonophonic statement from the previous example, since this method only applies to note playing and is not relevant at all when it comes to playing Groovoids or music files. We achieve the same kind of "monophonic" behavior as was seen in the previous step of the tutorial, just by virtue of the fact that a player instance can only play one file or Groovoid at a time.
Notice how the statements being executed for ONMOUSEOVER and ONCLICK events are exactly the same for each graphic. Each graphic is playing the same Groovoid when the user mouses over it. One thing that we no longer get, by using Groovoids, is the ability to easily play the mouseover sounds at different pitches.